//
//  JLUserCenter.swift
//  JLUserInfo
//
//  Created by Jiang Chencheng on 2024/7/31.
//

import Foundation
import JLApiCenter

public enum JLUserCenter {}

public extension JLUserCenter {
    private(set) static var userInfo: JLUserInfo?
}

public extension JLUserCenter {
    
    static func login() async throws -> Bool {
        let userInfo: JLUserInfo = try await JLApiCenter.request(.POST("login", ["mobile":"18301787178", "password": "123456"]))
        self.userInfo = userInfo
        return true
    }
    
    static func logout() async throws -> Bool {
        let userInfo: JLUserInfo = try await JLApiCenter.request(.POST("logout", [:]))
        self.userInfo = nil
        return true
    }
    
    static func register() async throws -> Bool {
        let userInfo: JLUserInfo = try await JLApiCenter.request(.POST("login", ["mobile":"18301787178", "password": "123456"]))
        self.userInfo = userInfo
        return true
    }
}
